<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>345登录</title>
		<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1.0, user-scalable=no" />  
		<link rel="stylesheet" href="css/mui.min.css">
		<script src="js/mui.min.js"></script>
		<style>
			* {
				border: 0px;
				padding: 0px;
				margin: 0px;
				font-family: "黑体";
			}
		</style>
		<script src="js/md5.js"></script>
		<script src="js/utils/http.utils.js"></script>
		<script type="text/javascript">
			var $rePhone = /^1[3|4|5|8][0-9]\d{4,8}$/;
			var $wxfwid = localStorage.getItem("wxfwid");
			function userLogin() {
				var $username = document.getElementById("ipt-username").value;
				if($username == null && $username == "") {
					mui.alert("请输入电话号码!");
					return;
				}
				if(!$rePhone.test($username)) {
					mui.alert("手机号格式不正确，请重新输入！");
					return;
				}

				var $password = document.getElementById("ipt-pword").value;
				if($password == null && $password == "") {
					mui.alert("请输入密码!");
					return;
				}
				mui.ajax({
					url: $request_url.userLogin,
					type: "post",
					headers: {
						"Authorization": $headers_authorization
					},
					data: {
						mobile: $username,
						password: hex_md5($password)
						//password: $password
					},
					dataType: "json",
					success: function(dat) {
						if(dat.code == 0) {
							
							localStorage.removeItem("login-user-parent");
							localStorage.removeItem("login-user-expert");
							//登录身份为家长
							if(dat.result.parent){
								localStorage.setItem("login-user-parent", JSON.stringify(dat.result));
								mui.openWindow({
									url : "index.html?orgId=" + $wxfwid
								}); 
							}
							//登录身份为专家
							if(dat.result.expert) {
								localStorage.setItem("login-user-expert", JSON.stringify(dat.result));
								mui.openWindow({
									url : "expert-index.html"
								});
							}
						} else {
							mui.toast(dat.message);
							return;
						} 
					},
					error: function(e) {
						mui.toast("请求失败，稍后重试....");
						return;
					}
				});
			}
		</script>

	</head>

	<body style="width: 100%; background-color: white;">
		<div id="tttt"></div>
		<div class="mui-content" align="center" style="background-color: white;">
			<div class="" style="margin-top: 30px;">
				<img src="img/login/logo_03.png" style="width: 90px;"/>
				<span style="color: #00A8C6; display: block;">家长无难事</span>
			</div>
			
			<div id="dv-login-up" style="width: 100%; margin-top: 20px;">
				
				<div style="background-image: url(img/login/kuang_03.png); background-repeat: no-repeat; background-size: 100%; height: 42px; width: 280px;">
					<div style="padding-top: 6px; display: flex; width: 100%;">
						<span style="display: block; margin-left: 5px;"><img src="img/login/dianhua_03.png" style="width: 18px;" /></span>
						<span style="display: block; margin-left: -10px;"><input id="ipt-username" type="tel" style="border: none; height: 24px; width: 90%; padding-left: 10px;" value="" placeholder="请输入手机号码"></span>
					</div>
				</div>
				
				<div style="background-image: url(img/login/kuang_03.png); background-repeat: no-repeat; background-size: 100%; height: 42px; width: 280px; margin-top: 15px;">
					<div style="padding-top: 6px; display: flex; width: 100%;">
						<span style="display: block; margin-left: 5px;"><img src="img/login/mima_07.png" style="width: 18px;" /></span>
						<span style="display: block; margin-left: -10px;">
							<input id="ipt-pword" style="border: none; height: 24px; width: 90%; padding-left: 10px;" type="password" value="" placeholder="请输入密码" />
						</span>
					</div>
				</div>
				
				<div class="" style="height: 70px; border: 0px; margin-top: 30px;">
					<button id='btn_login' onclick="userLogin();" type="button" style="border: 0px;">
						<img src="img/login/dengluanniu_03.png" style="width: 260px;" />
					</button>
				</div>
			</div>
			
			<div class="" style="font-size: 13px; color: #909090;">
				<span id="go-reg" style="color: #909090;">不是会员，去注册</span>
				<hr style="width: 110px; height: 1px; background-color: #DCDCDC; margin-top: 5px;" />
				<br />
				<a id="forget-pword" style="color: #909090;">忘记密码？求助&nbsp;&nbsp;
					<img src="img/login/jiantou_03.png" style="width: 8px;"></a><br />
				<hr style="width: 110px; height: 1px; background-color: #DCDCDC; margin-top: 5px;" />
			</div>
		</div>
	</body>
	<script src="js/mui.min.js"></script>
	<script src="js/utils/http.utils.js"></script>
	<script>
		document.getElementById("go-reg").addEventListener("tap", function(){
			mui.openWindow({
				url : $regRetUrl
			});
		});
	</script>
</html>